﻿<UserControl x:Class="xLibris.MenuView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="300">
    <Grid Name="root" Background="#c0000000">
        <Grid.RenderTransform>
            <TransformGroup>
                <ScaleTransform x:Name="scale" ScaleX="1" ScaleY="1"/>
            </TransformGroup>
        </Grid.RenderTransform>
        <Grid.Triggers>
            <EventTrigger RoutedEvent="Grid.Loaded" SourceName="root">
                <BeginStoryboard>
                    <Storyboard>
                        <DoubleAnimation Storyboard.TargetName="scale" Storyboard.TargetProperty="ScaleY" From="0" To="1" Duration="0:0:0.2"/>
                    </Storyboard>
                </BeginStoryboard>
            </EventTrigger>
        </Grid.Triggers>
        <TextBlock Text="{Binding CurrentMenu.Name}" Margin="16,4,0,0" Foreground="Silver" FontSize="14"/>
        <Border Margin="16,24,16,16" BorderBrush="White" BorderThickness="2" >
            <Border.Background>
                <LinearGradientBrush>
                    <GradientStop Offset="0" Color="#333333"/>
                    <GradientStop Offset="1" Color="#111111"/>
                </LinearGradientBrush>
            </Border.Background>
            <ScrollViewer VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Disabled">
                <ItemsControl ItemsSource="{Binding CurrentMenu.Children}">
                    <ItemsControl.ItemsPanel>
                        <ItemsPanelTemplate>
                            <WrapPanel />
                        </ItemsPanelTemplate>
                    </ItemsControl.ItemsPanel>
                    <ItemsControl.ItemTemplate>
                        <DataTemplate>
                            <Button Template="{DynamicResource GlasButton}" Width="148" Height="148" Margin="8" Command="{Binding ExecuteCommand}"  CommandParameter="{Binding Name}" >
                                <Grid>
                                    <Ellipse Width="8" Height="8" Stroke="White" StrokeThickness="1" Visibility="{Binding AppSign}"
                                             VerticalAlignment="Top" HorizontalAlignment="Left" Margin="0,0,0,0">
                                        <Ellipse.Fill>
                                            <LinearGradientBrush>
                                                <GradientStop Offset="0" Color="#ffffff"/>
                                                <GradientStop Offset="1" Color="#ff0000"/>
                                            </LinearGradientBrush>
                                        </Ellipse.Fill>
                                    </Ellipse>
                                    <StackPanel>
                                        <Image Width="96" Height="96" Source="{Binding Path=Icon}" VerticalAlignment="Top"/>
                                        <TextBlock Text="{Binding Name}" Foreground="White" FontSize="12" 
                                           Margin="4" HorizontalAlignment="Center" VerticalAlignment="Bottom"/>
                                    </StackPanel>
                                </Grid>
                            </Button>

                        </DataTemplate>
                    </ItemsControl.ItemTemplate>
                </ItemsControl>
            </ScrollViewer>
        </Border>
        <Button HorizontalAlignment="Right" VerticalAlignment="Top" Width="32" Height="32" Margin="2" Command="{Binding CloseCommand}" Visibility="{Binding CloseVisibility}">
            <EventTrigger RoutedEvent="Button.Click" SourceName="root">
                <BeginStoryboard>
                    <Storyboard>
                        <DoubleAnimation Storyboard.TargetName="scale" Storyboard.TargetProperty="ScaleX" From="1" To="0" Duration="0:0:0.2"/>
                    </Storyboard>
                </BeginStoryboard>
            </EventTrigger>
            <Button.Template>
                <ControlTemplate>
                    <Grid>
                        <Ellipse Stroke="White" StrokeThickness="2">
                            <Ellipse.Fill>
                                <LinearGradientBrush>
                                    <GradientStop Offset="0" Color="#ffc0c0"/>
                                    <GradientStop Offset="1" Color="#a00000"/>
                                </LinearGradientBrush>
                            </Ellipse.Fill>
                        </Ellipse>

                        <Line X1="10" Y1="10" X2="22" Y2="22" Stroke="White" StrokeThickness="4"/>
                        <Line X1="10" Y1="22" X2="22" Y2="10" Stroke="White" StrokeThickness="4"/>
                    </Grid>
                </ControlTemplate>
            </Button.Template>
        </Button>
    </Grid>

</UserControl>
